var Lock = function(){
}

Lock.prototype = {
    constructor:Lock ,
    wait: () => { // 等待锁
        this.flag = false ;
        return new Promise(resolve => {
          if (this.flag) {
            resolve(this.data);
          } else {
            this.resolve = resolve;
          }
        });
    } ,
    notify:  (data) => { // 通知锁
        this.data = data;
        this.flag = true;
        this.resolve && this.resolve(this.data);
    },
    flag:false ,
    data:{} ,
    getData:function(){
        return this.data
    }
}

  
  